function [Odata] = smoothPH(Idata,N,filter);

%This function smooths the input data by N number of points
%
%  
% function [Odata] = smoothPH(Idata,N,filter);
%
% N      = number of points to smooth over (rounds up to an odd number)
% filter = shape to convolve with: default is hamming. 
%          Boxcar, hanning, blackman are available.

% set defaults
if nargin<3;
  filter='hamming';
end

% make N odd
if rem(N,2)==0, N=N+1; end;

% set up filters 
switch filter
  case 'boxcar'
    fi=boxcar(N);
  case 'hanning'
    fi=hanning(N);
  case 'hamming'
    fi=hamming(N);
  case 'blackman'
    fi=blackman(N);
end
smnorm=ones(size(Idata));
Odata=conv(Idata,fi)./conv(smnorm,fi);
Odata(1:floor(N/2))=[];
Odata(end-floor(N/2)+1:end)=[];
